<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P161 【案例】标签栏切换效果</title>
</head>

<body>
    <div class="tab-box">
        <div class="tab-head">
            <div class="tab-head-div current">标签一</div>
            <div class="tab-head-div">标签二</div>
            <div class="tab-head-div">标签三</div>
            <div class="tab-head-div">标签四</div>
        </div>
        <div class="tab-body">
            <div class="tab-body-div current">1</div>
            <div class="tab-body-div">2</div>
            <div class="tab-body-div">3</div>
            <div class="tab-body-div">4</div>
        </div>
    </div>
    <script>
        var tabs = document.getElementsByClassName('tab-head-div');
        var divs = document.getElementsByClassName('tab-body-div');
        for (var i = 0; i < tabs.length; ++i) {
            tabs[i].onmouseover = function () {
                for (var i = 0; i < tabs.length; ++i) {
                    if (tabs[i] = this) {
                        divs[i].classList.add('current');
                        tabs[i].classList.add('current');
                    } else {
                        divs[i].classList.remove('current');
                        tabs[i].classList.remove('current');
                    }
                }
            };
        }
    </script>
    <a href="../首页/page07.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>